package com.reny.szkj.mvvmarts

import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavCallback
import com.reny.ll.git.base_logic.MActivity
import com.reny.ll.git.base_logic.config.RConfig
import com.reny.ll.git.base_logic.ext.delay
import com.reny.ll.git.base_logic.ext.router
import com.reny.szkj.mvvmarts.databinding.ActivitySplashBinding
import kotlinx.coroutines.Job

class SplashActivity : MActivity<ActivitySplashBinding>() {

    override fun isTransStatusBar(): Boolean = true

    override val layoutId: Int = R.layout.activity_splash

    private var job:Job? = null

    override fun initView() {}

    override fun onResume() {
        super.onResume()

        job = delay(1500L){
            router().build(RConfig.FtHome.main).navigation(this, object: NavCallback(){
                override fun onArrival(postcard: Postcard?) {
                    finish()
                }
            })
        }
    }

    override fun onPause() {
        super.onPause()
        try {
            job?.cancel()
        }catch (e:Exception){e.printStackTrace()}
    }

}